<template>
	<view class="enterComments" :style="{'bottom':height+'px'}" v-if="focus">
		<textarea class="enterComments_textarea" :adjust-position="false" placeholder-style="color:#CCCCCC" @blur="bindblur"
		 @focus="bindFocus" :focus="focus" :show-confirm-bar="false" placeholder="请输入评论..." v-model="commentContent" />
		<button :class="{'enterComments_btn':true,'enterComments_btn_active' : commentContent!='' ? true :false}" @click="onComments">发送</button>
	</view>
</template>

<script>
	export default {
		name: 'LhComment',
		props:{
			focus: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				height:0,  //评论
				commentContent:''
			}
		},
		methods: {
			// 评论-获取焦点
			bindFocus:function(e){
				this.height=e.detail.height
			},
			
			// 评论-失去焦点
			bindblur:function(e){
				this.$emit('blur')
			},
			
			// 发布评论
			onComments:function(){
				this.$emit('fixComments',this.commentContent)
				this.commentContent=''
			},
		}
	}
</script>

<style>
	.enterComments{
		padding: 20rpx 32rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		position: fixed;
		bottom: 200px;
		left: 0;
		right: 0;
		z-index: 99999;
	}
	
	.enterComments_textarea{
		width: 550rpx;
		height: 168rpx;
		padding:18rpx 28rpx ;
		box-sizing: border-box;
		border-radius: 18rpx;
		background: #F1F2F6;
		color: #333333;
	}
	
	.enterComments_btn{
		padding: 0;
		margin: 0;
		width: 92rpx;
		height: 58rpx;
		line-height: 58rpx;
		text-align: center;
		color: #FFFFFF;
		background:#DADADC ;
		border-radius: 12rpx;
		font-size: 28rpx;
	}
	
	.enterComments_btn_active{
		background: #FC8F8F;
	}
</style>
